{% extends "park/base.html" %}
{% block css %}
    <link rel="stylesheet" type="text/css" href="http://61.155.4.230:8807/arcgis_js_api/library/3.1/jsapi/js/dojo/dijit/themes/claro/claro.css">
    <style type="text/css">
    .mapEdit{
        right: 80px;
{#        top: -20px;#}
    }
    </style>
{% endblock %}
{% block body %}
    <body class="page-body page-fade skin-white claro" >
{% endblock %}
{% block content %}
        <script type="text/javascript">
            var primary_menu = "menu_0";
            var sub_menu = "menu_0_1";

            function checkedPoint(){
                var x=document.getElementById('geo_x').value,
                    y=document.getElementById('geo_y').value;
                
                if(!x || !y){
                    alert('未选择区域 禁止保存');
                    return false;
                }
            }

        </script>

            <div class="col-md-12">
                <div class="panel panel-primary">
                    <div class="panel-heading">
                        <div class="panel-title"><h3>园区地理位置编辑</h3></div>
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-md-12">
                                <form role="form" onsubmit="return checkedPoint();"  action="" method="post" enctype="multipart/form-data" class="form-horizontal form-groups-bordered">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">地理坐标</label>
                                        <div class="col-sm-10" style="margin-top: 10px">
                                            <div style="border: 1px solid #cccccc;padding: 10px;border-radius: 4px;width:90%;">
                                                <div data-dojo-type="dijit.layout.BorderContainer" design="headline" gutters="false" style="position:relative;width:100%; height:400px;">
                                                    <div id="map" dojotype="dijit.layout.ContentPane" region="center" style="overflow:hidden; height:400px;">
                                                        <div id="osmCopy" style="position:absolute; color:black;font-weight:bold;right:10px; bottom:10px; z-Index:999;"></div>
                                                    </div>
                                                </div>
                                                <div class="mapEdit">
                                                    <div class="panel-body">
                                                        <div id="toolbar" style="padding-left: 0px;padding-top:10px;padding-right: 0px;">
                                                            <div class="btn-group toolbar" >
                                                                <label id="cPosition" class="btn btn-white">
                                                                    <img title="点击获取地理坐标" src="/static/images/boundary.png">
                                                                </label>
                                                                <label id="undo" class="btn btn-white" onclick="undoManager.undo()">
                                                                    <img src="/static/images/undo.png">
                                                                </label>
                                                                <label id="redo" class="btn btn-white" onclick="undoManager.redo();">
                                                                    <img src="/static/images/redo.png">
                                                                </label>
                                                            </div>
                                                        </div>

                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <input name="geo_points" id='geo_points' type='hidden' />
                                        <input name="geo_center_point" id='geo_center_point' type='hidden' />
                                        <input name="geo_extent" id='geo_extent' type='hidden' />

                                        <input type='hidden' name="geo_x" id="geo_x"  />
                                        <input type='hidden' name="geo_y" id="geo_y"  />
                                        </div>

                                   <!-- <div class="form-group">
                                        <label class="col-sm-2 control-label">园区地图中心点经度</label>
                                        <div class="col-sm-3">
                                            <input type='hidden' name="geo_x" id="geo_x"  />

                                        </div>
                                        <label class="col-sm-2 control-label">园区地图中心点纬度</label>
                                        <div class="col-sm-3">
                                            <input type='hidden' name="geo_y" id="geo_y"  />
                                        </div>

                                    </div>  -->
                                    <div class="form-group">
                                        <div class="buttons">
                                            <input type="submit" onclick='return _checkPoints();' class="btn btn-success btn-lg" value="保存">
                                            <input class="btn btn-info btn-lg" type="reset" value="重置"/>
                                        </div>
                                    </div>
                                </form>
                            </div>

                        </div>
                    </div>
                </div>

            </div>


{% endblock %}
{% block js %}
<script type="text/javascript" src="http://61.155.4.230:8807/arcgis_js_api/library/3.1/jsapi/init.js"></script>
<script type="text/javascript" src="/static/js/map.companyPositionEdit.js"></script>
<script type="text/javascript">
    var e_points='';
    var p_points = '{{ p.geo_points }}';
    var geo_center_point = '{{ p.geo_center_point }}';
    var geo_extent = '{{ p.geo_extent | safe }}';

    if(geo_center_point){
        geo_center_point = eval(geo_center_point);
        $('#geo_x').val(geo_center_point[0]);
        $('#geo_y').val(geo_center_point[1]);
    }

    if(p_points) p_points = eval(p_points);

    if(geo_extent){
        geo_extent = JSON.parse(geo_extent);
    }

    $(function(){
        $('#cPosition').bind('click',function(){
            drowPolygon();
        });
    });



</script>
{% endblock %}